<?php
/*
 * RouterException
 * 
 * Excepció que gestiona els errors de la classe router
 */
class RouterException extends exception {

	const ERR_INV_CONT_PATH = 0;
	const ERR_CANNOT_READ_FILE = 1;
	const ERR_FILE_NOT_EXISTS = 2;
	const ERR_ACTION_NOT_AVAILABLE = 3;
	const ERR_INV_CONT_PATH_TXT = "Camí invalid al controlador";
	const ERR_CANNOT_READ_FILE_TXT = "No es pot llegir el fitxer";
	const ERR_FILE_NOT_EXISTS_TXT = "El fitxer no existeix";
	const ERR_ACTION_NOT_AVAILABLE_TXT = "Acció no disponible";
	
	
	private $aTxtError = array(self::ERR_INV_CONT_PATH => self::ERR_INV_CONT_PATH_TXT,
							self::ERR_CANNOT_READ_FILE => self::ERR_CANNOT_READ_FILE_TXT,
							self::ERR_FILE_NOT_EXISTS => self::ERR_FILE_NOT_EXISTS_TXT,
							self::ERR_ACTION_NOT_AVAILABLE => self::ERR_ACTION_NOT_AVAILABLE_TXT);

	private $aError;
	private $aCustomMsg;
	
	public function __construct($aError,$aMsg='') {
		$this->aError = $aError;
		$this->aCustomMsg = $aMsg != ''? ' ('.$aMsg.')' : '';
		parent::__construct($this->aTxtError[$this->aError].$this->aCustomMsg,$this->aError);
	}
	
/*	public function getMessage() {
		return $this->aTxtError[$this->aError].$this->aCustomMsg;
	} */
}  
?>
